#ifdef WITH_CG
#ifdef WITH_OPENGL

#include "shader_cg_opengl.h"

using namespace krryn::system_imp;

shader_cg_opengl::shader_cg_opengl(const std::string &a_Filename, CGcontext a_Context) : shader_cg(a_Filename, a_Context){
	m_VertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
	cgGLSetOptimalOptions(m_VertexProfile);

	m_PixelProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
	cgGLSetOptimalOptions(m_PixelProfile);

	init();

	cgGLLoadProgram(m_VertexShader);
	cgGLLoadProgram(m_PixelShader);
}

void shader_cg_opengl::enable(){
	m_Projection = cgGetNamedParameter(m_VertexShader, "projection");
	cgGLSetStateMatrixParameter(m_Projection, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );

	cgGLEnableProfile(m_VertexProfile);
	cgGLBindProgram(m_VertexShader);

	cgGLEnableProfile(m_PixelProfile);
	cgGLBindProgram(m_PixelShader);
}

void shader_cg_opengl::disable(){
	cgGLDisableProfile(m_VertexProfile);
	cgGLDisableProfile(m_PixelProfile);
}

#endif
#endif
